package com.huaru.message.controller;

import com.alibaba.fastjson.JSONObject;
import com.huaru.message.Vo.CourseVO;
import com.huaru.message.Vo.UsageRateVO;
import com.huaru.message.scheduling.CourseInfoThred;
import com.huaru.message.utile.CourseUtils;
import com.huaru.message.utile.UsageRateUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static com.huaru.message.config.StartMessage.COURSEINFOTHRED;

@RestController("/test")
public class TestController {

//    @RequestMapping("start")
//    public void  start(){
//        COURSEINFOTHRED =  new CourseInfoThred();
//        COURSEINFOTHRED.start();
//    }
//
//    @RequestMapping("stop")
//    public void  stop(){
//        COURSEINFOTHRED.stop();
//    }


    @RequestMapping("getCoueseList")
    public JSONObject getCoueseList(){
        List<CourseVO> courseList = CourseUtils.getCourseList();
        JSONObject jsonObject = new JSONObject();
        JSONObject jsonObject1 = new JSONObject();
        jsonObject.put("packType","CoueseList");
        jsonObject1.put("ip","192.168.100.1");
        jsonObject1.put("CoueseList",courseList);
        jsonObject.put("data",jsonObject1);
        return  jsonObject;
    }

    @RequestMapping("getCoueseInfo")
    public JSONObject getCoueseInfo(){
        UsageRateVO courseInfo = CourseUtils.getCourseInfo(2780);
        JSONObject jsonObject = new JSONObject();
        JSONObject jsonObject1 = new JSONObject();
        jsonObject.put("packType","CoueseInfo");
        jsonObject1.put("ip","192.168.100.1");
        jsonObject1.put("CoueseInfo",courseInfo);
        jsonObject.put("data",jsonObject1);
        return  jsonObject;
    }

    @RequestMapping("getUsageRate")
    public JSONObject getUsageRate(){
        UsageRateVO usageRate = UsageRateUtils.getUsageRate();
        JSONObject jsonObject = new JSONObject();
        JSONObject jsonObject1 = new JSONObject();
        jsonObject.put("packType","UsageRate");
        jsonObject1.put("ip","192.168.100.1");
        jsonObject1.put("UsageRate",usageRate);
        jsonObject.put("data",jsonObject1);
        return  jsonObject;
    }

}
